package com.ffyc.resale.service;

import com.ffyc.resale.dao.DataDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

// 数据统计业务层
@Service
@Transactional(rollbackFor = Exception.class)
public class DataService {

    @Autowired
    DataDao dataDao;

    public Map<String,Object> goodsBuyCountLine(){

        Map<String,Object> map = new HashMap<>();
        // x轴数据
        List<String> goodsTypeName = dataDao.goodsTypeName();
        // y轴数据
        List<Integer> goodsTypeBuyCount = dataDao.goodsTypeBuyCount();
        map.put("xdata",goodsTypeName);
        map.put("ydata", goodsTypeBuyCount);

        return map;
    }

    public List<Map<String,Integer>> goodsBuyCountPie(){

        List<Map<String,Integer>> map = dataDao.goodsCountPie();

        return map;
    }

}
